package com.lht.testDemo;

import org.junit.Test;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * @author Eric
 * @version 1.0
 * @date 2020-03-20
 */
public class SimpleDateFormartTest {


    @Test
    public void testMM() {
        SimpleDateFormat sdf = new SimpleDateFormat("MM");
        System.out.println(sdf.format(new Date()));
    }

    @Test
    public void test() {
        for (int i = 0; i < 1000; i++) {
            Random random = new Random();
            StringBuilder userNumber = new StringBuilder();
            int rand = random.nextInt(26) + 65;
            userNumber.append((char) rand);
            rand = random.nextInt(26) + 65;
            userNumber.append((char) rand).append(obtainRandomNumber(2));
            System.out.println(userNumber);
        }
    }

    /**
     * @param place
     * @return java.lang.String
     * @throws
     * @author Eric
     * @date 2020/1/5
     **/
    public static String obtainRandomNumber(int place) {
        StringBuilder num = new StringBuilder();
        num.append(new Random().nextInt(obtainDecimal(place)));
        while (num.length() < place) {
            num.append("0");
        }
        return num.toString();
    }

    public static int obtainDecimal(int place) {
        int math = 1;
        while (place > 1) {
            math *= 10;
            place--;
        }
        return math;
    }

}
